package com.zsh.rabbitmq.eight;

import com.rabbitmq.client.AMQP;
import com.rabbitmq.client.Channel;
import com.zsh.rabbitmq.utils.RabbitMQUtils;

/**
 * @author zsh
 * @Description 死信队列的生产者
 * @create 2022-05-06 10:40
 */
public class Producer {
    public static final String NORMAL_EXCHANGE = "normal_exchange";

    public static void main(String[] args) throws Exception {
        Channel channel = RabbitMQUtils.getChannel();

        //死信消息，设置TTL
        AMQP.BasicProperties properties =
                new AMQP.BasicProperties()
                        .builder().expiration("10000").build();


        for (int i = 0; i < 10; i++) {
            String msg = "info" + i;


            //需要传入参数
            channel.basicPublish(NORMAL_EXCHANGE,"zhangsan",null,msg.getBytes());
        }
    }
}
